package com.example.yls.demoa;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class MyFrontService extends Service {
    public MyFrontService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        /*reverseStr();*/
        /*Log.e("IBinder","onBind");*/
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");

    }

    /*private void reverseStr() {
        String str ="I LOVE ANDROID";
        String[]str1 =str.split(" ");
        StringBuffer resultBuffer = new StringBuffer();
        for(String str2 :str1){
            StringBuffer buffer1 =new StringBuffer(str2);
            resultBuffer.append(buffer1.reverse().append(" "));
        }

    }*/

    @Override
    public void onCreate() {
        super.onCreate();
        Intent intent = new Intent(MyFrontService.this,Main2Activity.class);
        PendingIntent pi =PendingIntent.getActivity(MyFrontService.this,
                0,intent,0);

        Notification notification = new Notification.Builder(MyFrontService.this)
                .setContentTitle("标题")
                .setContentText("内容")
                .setSmallIcon(R.mipmap.ic_launcher)

                .setWhen(System.currentTimeMillis())
                .setContentIntent(pi)
                .build();

        startForeground(1,notification);
    }
}
